import { Navigate } from "react-router-dom";
import { SmileOutlined, CrownOutlined, TableOutlined } from "@ant-design/icons";
import { Layout } from "@/layout";
import { NotPermission } from "@/pages/403";
import { NotFound } from "@/pages/404";
import Login from "@/pages/User/Login";

import Admin from "@/pages/Admin";
import Welcome from "@/pages/Welcome";
import TableList from "@/pages/TableList";
import TableDetail from "@/pages/TableList/detail";
export interface IRoute {
  path?: string;
  absPath?: string;
  id?: string;
  file?: string;
  parentId?: string;
  element?: React.ReactNode | null;
  icon?: React.ReactNode;
  children?: IRoute[];
  [key: string]: any;
}

// 业务路由配置
export const routes: IRoute[] = [
  {
    path: "/user",
    children: [
      {
        name: "login",
        path: "/user/login",
        element: <Login />,
      },
    ],
  },
  {
    layout: true,
    element: <Layout />,
    children: [
      {
        path: "/welcome",
        name: "welcome",
        icon: <SmileOutlined />,
        element: <Welcome />,
      },
      {
        path: "/admin",
        name: "admin",
        icon: <CrownOutlined />,
        children: [
          {
            path: "/admin",
            redirect: "/admin/sub-page",
          },
          {
            path: "/admin/sub-page",
            name: "sub-page",
            element: <Admin />,
          },
        ],
      },
      {
        name: "list.table-list",
        icon: <TableOutlined />,
        path: "/list",
        element: <TableList />,
      },
      {
        name: "list.table-list",
        icon: <TableOutlined />,
        path: "/list/detail",
        element: <TableDetail />,
      },
      {
        path: "/",
        element: <Navigate to="/welcome" />,
      },
    ],
  },
  {
    path: "/403",
    element: <NotPermission />,
  },
  {
    path: "/404",
    element: <NotFound />,
  },
  {
    path: "*",
    element: <Navigate to="/404" />,
  },
];

export default routes;
